package com.piz.dao.user;

import java.util.List;

import com.piz.dao.common.PizHiberImpl;
import com.piz.dao.common.UnexpectedDBException;
import com.piz.model.City;
import com.piz.model.Role;

/**
 * @author prameetk.sharma
 *
 */
public class RoleDao extends PizHiberImpl<Role>{
	
	
	/**
	 * @param role
	 * @return
	 */
	public Long saveRole(Role role)
	{
		try {
			saveOrUpdate(role);
			return role.getId();
		} catch (Exception e) {
			throw new UnexpectedDBException("Error in saving role details.", e);
		}
	}
	/**
	 * @param rolename
	 * @return
	 */
	public List<Role> getRoleByName(String rolename)
	{
		try {
			return (List<Role>) executeHQL("from Role where name ='"+rolename+"'");
		} catch (Exception e) {
			throw new UnexpectedDBException("DBException in fetching role by name.",e);
		}
		
	}

}
